package com.local.thread;

/*********************************************************************************
//* Copyright (C) 2015 Pingan Haoche (PAHAOCHE). All Rights Reserved.
//*
//* Filename:      TraditionalThreadSynchronized.java 
//* Revision:      1.0
//* Author:        <gao yunqi>
//* Created On:    2016年2月19日
//* Modified by:   
//* Modified On:   
//*
//* Description:   <传统线程之间的互斥>
/********************************************************************************/
public class TraditionalThreadSynchronized {

    /**
     * @param args
     */
    public static void main(String[] args) {
        new TraditionalThreadSynchronized().init();

    }
    public void init (){
        final ArrayUtil  arrayUtil = new ArrayUtil();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        arrayUtil.traversalArray(new String[]{"1","2"});
                    }
                }
            }).start();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        arrayUtil.traversalArray(new String[]{"a","b"});
                    }
                }
            }).start();

    }

    class ArrayUtil{
        public  void traversalArray(String [] param){
            for (int i = 0; i < param.length; i++) {
                System.out.print(param[i]);
            }
            System.out.println();
        }
    }

}